package com.rainng.coursesystem.controller.student;

import com.rainng.coursesystem.model.vo.response.ResultVO;
import com.rainng.coursesystem.model.vo.response.table.StudentExamItemVO;
import com.rainng.coursesystem.service.student.ExamService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ExamController {

    private final ExamService examService;

    // 构造函数注入 ExamService
    public ExamController(ExamService examService) {
        this.examService = examService;
    }

    /**
     * 获取指定学生的考试信息
     * @param studentId 学生ID
     * @return 学生的考试信息
     */
    @GetMapping("/student/exam/list")
    public List<StudentExamItemVO> getExamsByStudentId(@RequestParam Integer studentId) {

        System.out.println("Received studentId: " + studentId);
        // 获取学生的考试信息
        List<StudentExamItemVO> exams = examService.getExamsByStudentId(studentId);

        // 返回查询结果，前端直接接收列表
        return exams;
    }

}
